'use strict';
var createItem = require('./createItem.js');
var editItem = require('./editItem.js');
var app = getApp();

function saveTextFields(temporalItem) {
    if ((temporalItem.name != '') && (temporalItem.name != undefined)) {
        if ((temporalItem.notice == '') || (temporalItem == undefined)) {
            temporalItem.notice = '请输入'
        }
        if ((app.globalData.user_form[0].edit == false) || (app.globalData.user_form[0].edit == undefined)) {
            createItem('text_fields', temporalItem);
        } else if (app.globalData.user_form[0].edit == true) {
            editItem(temporalItem);
        }
        //返回上一个页面
        wx.navigateBack({
            url: '../items'
        })
    } else {
        wx.showModal({
            title: '提示',
            content: '请输入字段名称',
            showCancel: 'false'
        })
    }
}
module.exports = saveTextFields;